class_name CardPool
extends Resource

var card_list: Array[Card] = []

signal card_added
signal card_removed
signal shuffled
signal drawed


## 添加卡牌(Add Card)：将卡牌添加到牌组中。
func add_card(card) -> void:
	if card != null:
		card_list.append(card)


func add_card_front(card) -> void:
	card_list.push_front(card)
## 移除卡牌(Remove Card)：从牌组中移除卡牌。


func remove_card() -> void:
	pass


## 洗牌(Shuffle)：将牌组中的卡牌重新洗牌。
func shuffle() -> void:
	card_list.shuffle()


## 抽牌(Draw Card)：从牌组中抽取卡牌。
func draw_card() -> Card:
	if card_list.size() == 0:
		pass
	shuffle()
	var card: Card = card_list.pop_front()
	return card
	
func draw_card_no_shuffle() -> Card:
	if card_list.size() == 0:
		pass
	var card: Card = card_list.pop_front()
	return card

func get_card_count() -> int:
	return card_list.size()


func end_battle():
	card_list.clear()


func move_top(card_id):
	var index = -1
	for i in range(card_list.size()):
		var card = card_list[i]
		if card_id == card.card_id:
			index = i
	if index != -1:
		var temp = card_list.pop_at(index)
		card_list.push_front(temp)
		return true
	return false
